void init_I2C0(void)
{
	mux_PINS(0,4,0x1);
	mux_PINS(0,5,0x1);

	adi_i2c_Open(0,&I2C0_MemorySize,ADI_I2C_MEMORY_SIZE,&handle_I2C0);

	adi_i2c_SetBitRate(handle_I2C0,400000);
	adi_i2c_SetSlaveAddress(handle_I2C0,MCP79412_EEPROM_Slave_Add);
}
uint8_t I2C0_Send_add_Read_1(uint8_t slave_add,uint8_t add,bool RepeatStart)
{
	mux_PINS(0,4,0x1);
	mux_PINS(0,5,0x1);
	
	adi_i2c_SetSlaveAddress(handle_I2C0,slave_add);
	uint32_t error=0;
	uint8_t I2C0_Prologue[1]={add};
	uint8_t I2C0_Data[1]={0};
	ADI_I2C_TRANSACTION I2C0_Trans;
	I2C0_Trans.bReadNotWrite=true;
	I2C0_Trans.bRepeatStart=RepeatStart;
	I2C0_Trans.pPrologue=I2C0_Prologue;
	I2C0_Trans.nPrologueSize=1;
	I2C0_Trans.pData=I2C0_Data;
	I2C0_Trans.nDataSize=1;
	
	adi_i2c_ReadWrite(handle_I2C0,&I2C0_Trans,&error);	
	return I2C0_Data[0];
}

uint16_t I2C0_Send_add_Read_2(uint8_t slave_add,uint8_t add,bool RepeatStart)
{
	mux_PINS(0,4,0x1);
	mux_PINS(0,5,0x1);
	
	adi_i2c_SetSlaveAddress(handle_I2C0,slave_add);
	uint32_t error=0;
	uint8_t I2C0_Prologue[1]={add};
	uint8_t I2C0_Data[2]={0,0};
	ADI_I2C_TRANSACTION I2C0_Trans;
	I2C0_Trans.bReadNotWrite=true;
	I2C0_Trans.bRepeatStart=RepeatStart;
	I2C0_Trans.pPrologue=I2C0_Prologue;
	I2C0_Trans.nPrologueSize=1;
	I2C0_Trans.pData=I2C0_Data;
	I2C0_Trans.nDataSize=2;
	
	adi_i2c_ReadWrite(handle_I2C0,&I2C0_Trans,&error);	
	return ((I2C0_Data[0]<<8)&0xFF00)|I2C0_Data[1];
}

uint8_t I2C0_Send_add_Write_1(uint8_t slave_add,uint8_t add,uint8_t dat,bool RepeatStart)
{
	mux_PINS(0,4,0x1);
	mux_PINS(0,5,0x1);
	
	adi_i2c_SetSlaveAddress(handle_I2C0,slave_add);
	uint32_t error=0;
	uint8_t I2C0_Prologue[1]={add};
	uint8_t I2C0_Data[1]={dat};
	ADI_I2C_TRANSACTION I2C0_Trans;
	I2C0_Trans.bReadNotWrite=false;
	I2C0_Trans.bRepeatStart=RepeatStart;
	I2C0_Trans.pPrologue=I2C0_Prologue;
	I2C0_Trans.nPrologueSize=1;
	I2C0_Trans.pData=I2C0_Data;
	I2C0_Trans.nDataSize=1;
	
	adi_i2c_ReadWrite(handle_I2C0,&I2C0_Trans,&error);	
	return dat;
}


